package abstractFactory;

import abstractFactory.factory.AbsFactory;
import abstractFactory.factory.Impl.BJFactory;
import abstractFactory.factory.Impl.LDFactory;
import abstractFactory.pizza.Pizza;

/**
 * @author : DuJiabao
 * @Date : 2021/3/1 21:48
 * @Project : design-pattern
 * @File : null.java
 * @Desc :
 */
public class OrderPizza {
  private AbsFactory factory;

  public OrderPizza(AbsFactory factory) {
    this.factory = factory;
  }

  public void setFactory(AbsFactory factory) {
    this.factory = factory;
  }

  public void make(String name) {
    Pizza pizza = factory.createPizza(name);
    pizza.prepare();
    pizza.bake();
    pizza.cut();
    pizza.box();
  }

  public static void main(String[] args) {
    OrderPizza orderPizza = new OrderPizza(new BJFactory());
    orderPizza.make("Cheese");
    orderPizza.make("Pepper");
    orderPizza.setFactory(new LDFactory());
    orderPizza.make("Cheese");
    orderPizza.make("Pepper");
  }

}
